/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package UserInterface;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


/**
 *Frame global de l'application Cyrene
 * @author Julien
 */
public class GUI extends DisplayManager implements ActionListener{

    protected JFrame fenetre = new JFrame();
    protected JPanel north = new JPanel();
    protected JPanel south = new JPanel();
    
    protected JLabel titre = new JLabel("Application de gestion des notations");
    protected JPanel panneauBoutons = new JPanel();

    protected JButton deconnexion = new JButton("Deconnexion");
    protected JButton accueil = new JButton("Accueil");
    protected JButton gestionProfils = new JButton("Gestion des profils");
    protected JButton gestionApogee = new JButton("Gestion Apogee");
    protected JButton gestionDeLaNotation = new JButton("Gestion Notation");

    protected JLabel jLabel2 = new JLabel();

    protected JPanel conteneurComplement = new JPanel();

    protected JLabel copyright = new JLabel();
    
   
    
    
/**
 * constructeur
 */
    public GUI()
    {
    	
        this.fenetre.setVisible(true);
        this.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.fenetre.setSize(1000, 700);
        this.fenetre.setMinimumSize(new Dimension(1000, 700));
        this.fenetre.setTitle("Cyrene");
        
        
        this.initFrame();
        
        //this.fenetre.pack();
        
    }
   

    /**
     * initialisation 
     */
    public void initFrame() {

    	Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
      	this.fenetre.setLocation((screen.width - this.fenetre.getSize().width)/2,(screen.height - this.fenetre.getSize().height)/2);
        this.fenetre.setLayout(new BorderLayout());
        this.fenetre.add(north, BorderLayout.NORTH);
        this.fenetre.add(south, BorderLayout.CENTER);
        this.deconnexion.addActionListener(this);

        this.north.setLayout(new BorderLayout());
        this.south.setLayout(new BorderLayout());

        this.titre.setFont(new java.awt.Font("Tahoma", 0, 24));
        this.titre.setForeground(new java.awt.Color(0, 153, 153));
        this.titre.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        this.north.add(this.titre,BorderLayout.CENTER);
        this.north.add(this.jLabel2,BorderLayout.WEST);
        
        this.south.add(this.conteneurComplement,BorderLayout.CENTER);
        	
        
        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("petitLogo.jpg")));
        

        initPanBoutons();

        this.south.add(this.panneauBoutons,BorderLayout.WEST);
        this.panneauBoutons.setPreferredSize(new Dimension(200,200));      

        
       

        this.copyright.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        this.copyright.setForeground(new java.awt.Color(0, 153, 153));
        this.copyright.setText("                "
                + "                            "
                + "           "
                + "                           "
                + "                           "
                + " Cyrene - Polytech Montpellier - IG4 - 2010/2011");

        this.fenetre.add(this.copyright,BorderLayout.SOUTH);
       this.fenetre.pack();

    }


    public void initPanBoutons()
    {
           this.panneauBoutons.setLayout(new GridBagLayout());
           GridBagConstraints c = new GridBagConstraints();
           c.anchor = GridBagConstraints.WEST;
           c.insets = new Insets(0, 0, 0, 0);

           c.gridx = 0;
            c.gridy = 0;
           c.gridwidth = 1;
           c.gridheight = 1;
           c.weightx = 1;
           c.weighty = 1;

           this.panneauBoutons.add(this.deconnexion,c);


           c.gridx = 0;
            c.gridy = 1;


           this.panneauBoutons.add(this.accueil,c);
           this.accueil.addActionListener(this);


           c.gridx = 0;
            c.gridy = 2;

           this.panneauBoutons.add(this.gestionApogee,c);
           this.gestionApogee.addActionListener(this);


           c.gridx = 0;
            c.gridy = 3;
            
            this.panneauBoutons.add(this.gestionDeLaNotation,c);
            this.gestionDeLaNotation.addActionListener(this);

            
            c.gridx = 0;
            c.gridy = 4;

           this.panneauBoutons.add(this.gestionProfils,c);
           this.gestionProfils.addActionListener(this);

           this.deconnexion.setPreferredSize(this.gestionProfils.getPreferredSize());
           this.accueil.setPreferredSize(this.gestionProfils.getPreferredSize());
           this.gestionApogee.setPreferredSize(this.gestionProfils.getPreferredSize());
           
           this.panneauBoutons.setPreferredSize(new Dimension(150,100));
    }


    public void display() {
        throw new UnsupportedOperationException("Not supported yet.");
    }



		public void actionPerformed(ActionEvent e) {

		    if(e.getSource()==deconnexion){
		        this.fenetre.dispose();
		        Login log = new Login();
		    }
		    
		    if( e.getSource()==gestionDeLaNotation){
		    	GUINotation suiv = new GUINotation();
		    	this.fenetre.dispose();
		    }	
		    
		    if( e.getSource()==accueil){
		    	   this.fenetre.dispose();
	           	Accueil suiv = new Accueil();
			    }

	    }



}


